﻿IF  EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[esf_files].[P_IncrementFileReferenceDownloadCount]') AND type in (N'P', N'PC'))
	DROP PROCEDURE [esf_files].P_IncrementFileReferenceDownloadCount
GO


CREATE PROCEDURE esf_files.P_IncrementFileReferenceDownloadCount
	@pLastDownloadUserAlias VARCHAR (20),
	@pID INT
AS
	UPDATE 
		[esf_files].[FileReference] 
	SET 
		DownloadCount = DownloadCount + 1,
		LastDownloadUserAlias = @pLastDownloadUserAlias,
		LastDownloadDateTime = GETDATE ()
	WHERE
		ID = @pID